package main;
import java.io.*;
public class seperateFile {
	public static void ReadData() {  
        try {  
            FileReader read = new FileReader("D:/data.txt");  
            BufferedReader br = new BufferedReader(read);  
            String row;  
            int rownum = 1;  
            FileWriter fw1 = new FileWriter("/text1.txt");  
            FileWriter fw2 = new FileWriter("/text2.txt");  
            FileWriter fw3 = new FileWriter("/text3.txt");  
            FileWriter fw4 = new FileWriter("/text4.txt");  
            while ((row = br.readLine()) != null) {  
                if (rownum % 4 == 1) {  
                    fw1.append(row + "\r\n");  
                } else if (rownum % 4 == 2) {  
                    fw2.append(row + "\r\n");  
                } else if (rownum % 4 == 3) {  
                    fw3.append(row + "\r\n");  
                } else if (rownum % 4 == 0) {  
                    fw4.append(row + "\r\n");  
                }  
                rownum++;  
            }  
            fw1.close();  
            fw2.close();  
            fw3.close();  
            fw4.close();  
  
        } catch (FileNotFoundException e) {  
            e.printStackTrace();  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  
  
}  
}
